package com.dmj.sqldsl.platform;

import com.dmj.sqldsl.builder.exception.UnknownException;
import com.dmj.sqldsl.executor.SqlDialect;
import lombok.Getter;

@Getter
public enum H2Mode {
  h2(""),
  mysql(";MODE=MYSQL"),
  postgresql(";MODE=PostgreSQL"),
  oracle(";MODE=Oracle"),
  sqlserver(";MODE=MSSQLServer"),

  real_mysql(""),
  real_postgresql(""),
  real_oracle(""),
  real_sqlserver("");

  private final String dialect;

  H2Mode(String dialect) {
    this.dialect = dialect;
  }

  public SqlDialect toSqlDialect() {
    switch (this) {
      case h2:
        return SqlDialect.h2;
      case mysql:
      case real_mysql:
        return SqlDialect.mysql;
      case postgresql:
      case real_postgresql:
        return SqlDialect.postgresql;
      case oracle:
      case real_oracle:
        return SqlDialect.oracle;
      case sqlserver:
      case real_sqlserver:
        return SqlDialect.sqlserver;
    }
    throw new UnknownException();
  }
}
